package com.ashes.brave.service.impl;


import com.ashes.brave.mapper.MenuSysMapper;
import com.ashes.brave.service.MenuSysService;
import com.ashes.oppo.po.SysAshesMenuPO;
import com.ashes.security.frame.MenuHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author chengxuhui
 */
@Service
public class MenuAdminServiceImpl implements MenuSysService {

    @Autowired
    private MenuSysMapper menuSysMapper;


    /**
     * 获取用户权限
     * @param userId
     * @return
     */
    @Override
    public List<String> queryPermsByUserId(BigDecimal userId) {
        List<String> permsList = menuSysMapper.queryPermsByUserId(userId);
        return permsList;
    }

    /**
     * 获取用户路由菜单
     * @param userId
     * @return
     */
    @Override
    public List<String> selectRouterByUserId(BigDecimal userId) {
        //先查询用户id
        List<SysAshesMenuPO> menus = menuSysMapper.queryMenuListData(userId);
        //将menus转换为树形结构
        List<SysAshesMenuPO> sysAshesMenuPOS = MenuHelper.buildTree(menus);
        //todo 未完成路由

        List<String> routers = menuSysMapper.queryRouterListData(userId);
        return routers;
    }


}
